﻿@{
    Layout = null;
}
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <meta name="format-detection" content="telephone=no,email=no">
    <title>你说我说</title>
    <!-- 基础css begin -->
    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/pkg/css/base.css">
    <!-- 基础css end -->
    <!-- 组件依赖css begin -->
    <!--<link rel="stylesheet" href="css/widget/button/button.default.css">-->
    <!--<link rel="stylesheet" href="css/widget/button/button.css">-->
    <!--<link rel="stylesheet" href="css/widget/modal/modal.css">-->
    <!--<link rel="stylesheet" href="css/widget/progressbar/progressbar.default.css">-->
    <!--<link rel="stylesheet" href="css/widget/progressbar/progressbar.css">-->
    <!--<link rel="stylesheet" href="css/widget/progressbar/progressbar.iOS7.css">-->
    <!-- 组件依赖css end -->
    <!-- 页面css begin -->
    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/pkg/css/layout.css">
    <!-- 页面css begin -->

    <link type="text/css" rel="stylesheet" href="/Content/BenzXH/css/max.css">
    <style>
        .icon.icon-praised:before {
            background-image: url(/Content/BenzXH/images/praise.png?__sprite);
        }
    </style>
</head>
<body>
    <div class="background-full"></div>
    <div id="wrapper">
        <div id="content">
            <section>
                <div class="art-list">
                    <ul id="articlelist">
                        <li class="p-topic">
                            <a href="/benzxh/publish"><span class="icon icon-add"></span><span>发布话题</span></a>
                        </li>
                        @*<li>
                                <div class="art-title topic"><span class="icon icon-top"></span><span>心所向 持以恒</span></div>
                                <div>
                                    <span class="time">2015-03-15</span>
                                    <p><span class="icon icon-ambia"></span><span>1680</span></p>
                                    <p><span class="icon icon-eyes"></span><span>2750</span></p>
                                    <p><span class="icon icon-comments"></span><span>1500</span></p>
                                </div>
                            </li>*@
                    </ul>
                    <div id="loadingText" class="text-center">正在加载...</div>
                    @*<button id="article_more" type="button" class="default-button margin-top-20 width-full" onclick="BindArticles(10)" style="display: none;">更多文章</button>*@
                </div>
            </section>
        </div>
    </div>

    <!-- 组件依赖js begin -->
    <!--<script src="js/dist/zepto.min.js"></script>-->
    <!--<script src="js/extend/compatibleIE9.js"></script>-->
    <!--<script src="js/extend/selector.js"></script>-->
    <!--<script src="js/extend/fastclick.js"></script>-->
    <!-- 组件依赖js end -->
    <!-- 公用js begin -->
    <!--<script src="js/script.js"></script>-->
    <!-- 公用js begin -->
    <script type="text/javascript" charset="utf-8" src="/Content/BenzXH/pkg/js/core.js"></script>
    <script src="/Content/benzxh/js/scroll/scrollpagination.js?ver=201512071548"></script>
    <script src="/Content/benzxh/js/common.js?ver=201511261333"></script>
    <script type="text/javascript">
        var pageIndex = 1;
        BindArticles(10);
        function BindArticles(pageSize) {
            pageSize = pageSize || 10;
            $("#articlelist").scrollPagination({
                //contentPage: "/benzxh/getarticlelist?categoryId=8&pageIndex=" + pageIndex + "&pageSize=" + pageSize,
                contentData: {},
                scrollTarget: $(window),
                heightOffset: 10,
                beforeLoad: function (options) {
                    $("#loadingText").show();
                    options.contentPage = "/benzxh/getarticlelist?categoryId=8&pageIndex=" + pageIndex + "&pageSize=" + pageSize;
                },
                appendItems: function (objInvokeResult) {
                    $("#loadingText").hide();

                    if (objInvokeResult.ResultCode == "ArticleInfoNull") {
                        //todo：移除更多事件
                        $("#article_more").removeAttr("onclick");
                        $("#article_more").hide();
                        //停止滚动加载
                        $("#articlelist").stopScrollPagination();
                        return;
                    }
                    if (objInvokeResult.ResultCode != "Success") {
                        alert(objInvokeResult.ResultMessage);
                        return;
                    }
                    if (objInvokeResult.Data.length < pageSize) {
                        //停止滚动加载
                        $("#articlelist").stopScrollPagination();
                        $("#article_more").removeAttr("onclick");
                        $("#article_more").hide();
                    } else {
                        //$("#article_more").show();
                    }
                    var html = "";
                    $.each(objInvokeResult.Data, function (i, objArticleResultInfo) {
                        html += CreateArticleHtml(objArticleResultInfo);
                    });

                    $("#articlelist").append(html);

                    pageIndex++;
                },
                afterLoad: function (objInvokeResult) {

                }
            });
        }

        function CreateArticleHtml(objArticleResultInfo) {
            var html = "";
            if (typeof (objArticleResultInfo) == "undefined" || typeof (objArticleResultInfo.ArticleInfo) == "undefined") {
                return html;
            }
            var objArticleInfo = objArticleResultInfo.ArticleInfo;
            html =
                '<li onclick="window.location.href=\'/benzxh/article/thread-topic/' + objArticleInfo.ArticleId + '\'">' +
                    '<div class="art-title"><span>' + objArticleInfo.ArticleTitle + '</span></div>' +
                    '<div>' +
                        '<span class="time">' + JsonToDate(objArticleInfo.CreateDate, false) + '</span>' +
                        '<p><span class="icon ' + (objArticleInfo.IsDigg ? 'icon-praised' : 'icon-ambia') + '"></span><span>' + objArticleInfo.DiggCount + '</span></p>' +
                        '<p><span class="icon icon-eyes"></span><span>' + objArticleInfo.ViewCount + '</span></p>' +
                        '<p><span class="icon icon-comments"></span><span>' + objArticleInfo.CommentCount + '</span></p>' +
                    '</div>' +
                '</li>'
            return html;
        }
    </script>
</body>
</html>